package com.kara.woodAgent.agent.model.impl;

import com.kara.woodAgent.agent.model.ModelProvider;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.ollama.OllamaChatModel;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

@ConditionalOnProperty(prefix = "model.use", name = "enable", havingValue = "ollama")
@Component
public class OllamaModelProvider implements ModelProvider {
    private ChatLanguageModel chatModel;

    @Value("${model.ollama.baseUrl}")
    private String baseUrl;

    @Value("${model.ollama.name}")
    private String model;

    @PostConstruct
    public void init() {
        chatModel = OllamaChatModel.builder()
                .baseUrl(baseUrl)
                .modelName(model)
                .build();
    }

    @Override
    public ChatLanguageModel getChatModel(String type) {
        return chatModel;
    }
}
